package com.example;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


import java.io.IOException;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;

/**
 *
 * @author Shameera
 */
public class ZipReader {

    private final String fileName;

    public ZipReader(String fileName) throws IOException {
        this.fileName = fileName;
        readContent();
    }

    public void readContent() throws IOException {   // worked
       try {
            String inFileName = fileName;
            ZipFile zf = new ZipFile(inFileName);
            Enumeration entries = zf.entries();
            System.out.println("=============FILES IN ARCHIEVE============");
            while (entries.hasMoreElements()) {
                ZipEntry entry = (ZipEntry) entries.nextElement();
                System.out.println("name : " + entry.getName() + " size : " + entry.getSize());
            }//Close File
            zf.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static void main(String args[]) {
        try {
            String inFileName = "E:\\myfile.odt";
            ZipFile zf = new ZipFile(inFileName);
            Enumeration entries = zf.entries();
            System.out.println("=============FILES IN ARCHIEVE============");
            while (entries.hasMoreElements()) {
                ZipEntry entry = (ZipEntry) entries.nextElement();
                System.out.println("name : " + entry.getName() + " size : " + entry.getSize());
            }//Close File
            zf.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }//End main
    
}
